package com.quan.common.scheduler;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.quan.sdk.weixin.tools.JsApiTicketTools;

/**
 * 定时获取JsApiTicket，每个1小时55分获取一次
 * @author yhaoquan
 *
 */
@Component
public class JsApiTicketRefreshTask {
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@PostConstruct
	public void initMethod() {
		this.accessTokenRefreshJob();
	}
	
	/**
	 * 0/5 * * * * ? 	  每5秒执行一次
	 * 0 55 0/1 * * ?	 每个1小时55分获取一次
	 */
	@Scheduled(cron = "0 55 0/1 * * ?")
	public void accessTokenRefreshJob() {
		logger.info("------------------------每隔1小时55分定时获取JsApiTicket");
		JsApiTicketTools.getAccessToken();
		
	}
}
